<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
header("Access-Control-Allow-Origin:*");
/* @var $this yii\web\View */
/* @var $form yii\widgets\ActiveForm */
/* @var $model app\models\LoginForm */

$this->title = '登录';
?>
<?=Html::cssFile('@web/css/common.css')?>
<?=Html::cssFile('@web/css/login.css')?>
<?=Html::cssFile('@web/css/animate.css')?>
<?=Html::jsFile('@web/js/jquery-1.11.3.min.js')?>
<?=Html::jsFile('@web/js/verify.js')?>
<?=Html::jsFile('@web/js/dl.js')?>
<?=Html::jsFile('@web/js/login.js')?>

<body>
<div class="conter">
    <div class="conter_left">
        <img src="../images/earth.png" style="width: 49%"/>
        <p class="animated fadeInUp">深度资金图谱平台</p>
    </div>
    <div class="conter_right">
        <div class="login">
            <div style="width: 54%;height: 50%;">
                <ul>
                    <li>
                        <div>
                            <img src="../images/yhm-icon.png" alt="" />
                        </div>
                        <input name="uname" type="text" placeholder="请输入账号" id="put1" value="" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();"maxlength="11"/>
                    </li>
                    <li>
                        <div>
                            <img src="../images/mm-icon.png" alt="" />
                        </div>
                        <input name="upwd" type="password" placeholder="请输入密码" id="put2" value="" />
                    </li>
                    <li>
                        <div>
                            <img src="../images/yzm-icon.png" alt="" />
                        </div>
                        <input type="text" placeholder="请输入验证码" id="put3" maxlength="4"/>
                    </li>
                    <div id="mpanel2"></div>
                    <div class="clearfix"></div>
                </ul>

                <div class="checkbox">
                    <a href="#" class="fr">找回密码</a>
                    <span class="fr" style="margin-right: 5%;">记住密码</span>
                    <div id="checkbox" class="fr"></div>
                    <input type="checkbox" name="" id="" value="" /style="display: inline-block;float: right;margin: 1.5% 3% 0 0;">
                    <div class="clearfix"></div>
                </div>
                <a class="button login_button" onclick="getText()">登 &nbsp;&nbsp;&nbsp;陆</a>
                <div class="text"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).on('click','.button',function () {
        var uname = $('#put1').val();
        var password = $('#put2').val();
        var code2 = $('#put3').val();
        // 正则表达式开始
        // 验证码
//        var yz = /^1(([358]{1}[0-9]{1})|(47|70|76|77))[0-9]{8}$/;
//        var myreg = /^1(([358]{1}[0-9]{1})|(47|70|76|77))[0-9]{8}$/;
//        if(uname == ''){
//            alert('手机号不能为空')
//            $('#put1').attr('placeholder','手机号不能为空')
//        }else if(!myreg.test(uname)) {
//            alert('手机号格式不正确')
//            $('#put1').attr('placeholder','手机号格式不正确')
//            return false;
//        }
//        if(code2 == "") {
//            alert('验证码不能为空')
//            $('#put1').attr('placeholder','验证码不能为空')
//            return false;
//        }
        // 验证验证码
        // if(yz.test(code2)) {
        //     $.ajax({
        //         type: 'POST',
        //         url: '/index.php/Login/phonelogin.html',
        //         data: {
        //             phone: user2,
        //             code: code2
        //         },
        //         async:false,
        //         success: function(mes) {
        //             if(mes == "正常") {
        //                 location.reload();
        //
        //             } else if(mes == "初次") {
        //                 window.location.href = '';
        //             } else if(mes == "请输入有效验证码") {
        //                 $(".error1").text("请输入有效验证码")
        //             }
        //         },
        //         error: function() {
        //             alert('数据有误请重试!!！');
        //         }
        //     });

        $.ajax({
            type:'post',
            url:'http://172.18.80.9:8087/admin/login/check',
            data:{
                user_name:uname,
                pwd:password
            },
            error:function(error){
                console.log(error);
            },
            success:function (data) {


                var msg=jQuery.parseJSON(data);
                if (msg.code == 0){
                    alert("yes");
                    location.href = 'http://172.18.80.9:8087/admin/login/choicerole';
                    var a = msg.data
                    sessionStorage.setItem('msg_data',JSON.stringify(a));
                }else if (msg.code != 0){
                    alert("no")
                }

            }
        });


    });
    $(function () {
        var b =	sessionStorage.getItem('msg_data')
        console.log(b)
    })

    $('#mpanel2').codeVerify({
        type : 1,
        width : '100%',
        height : '25%',
        fontSize : '1.8vw',
        codeLength : 4,
        btnId : 'check-btn',
        ready : function() {
        },
        success : function() {
            alert('验证匹配！');
        },
        error : function() {
            alert('验证码不匹配！');
        }
    });
</script>
</body>

</html>
<?php exit;?>
